#!/usr/bin/python3
import random
from typing import Callable


def binary_search(lst, item) -> int:
    low = 0
    high = len(lst) - 1

    while low <= high:
        mid = (low + high) // 2
        guess = lst[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid - 1
        else:
            low = mid + 1
    return None


# def binary_search(list: list[int], data: int):
#     n = len(list)
#     mid = n // 2
#     if list[mid] > data:
#         return binary_search(list[0:mid], data)
#     elif list[mid] < data:
#         return binary_search(list[mid + 1 :], data)
#     else:
#         return mid


def main(size: int = 10, search: Callable = binary_search):
    """
    docstring
    """
    lyst: int = []
    num: int = 1
    for count in range(size):
        num = num + random.randint(1, 9)
        lyst.append(num)

    data: int = lyst[random.randint(0, size - 1)]

    print(lyst)
    result = search(lyst, data)
    print(data, result)


if __name__ == "__main__":
    main(search=binary_search)
